<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cells {
    margin-top: 0;
  }
  .weui-cells_form {
    background: #fbfbfb;
  }
  .weui-cell {
    background: #fff;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label{
    /*width: 130px;*/
    text-align: left;
  }

  .weui-select {
    height: auto;
    line-height: normal;
  }

  .weui-navbar a{
    text-decoration: none;color: #333;
  }

  .weui_tab_bd_item{
    display:none;height: 100%;overflow: auto;
  }

  .weui_tab_bd_item.weui_tab_bd_item_active{
    display:block;
  }

  *{
    list-style:none;
  }
  .delsty {
    position: absolute;
    top: 2px;
    right: 0px;
    z-index: 1000;
  }
  /*body{*/

  /*}*/

  .weui_uploader_input_wrp {
    float: left;
    position: relative;
    margin-right: 9px;
    margin-bottom: 9px;
    width: 77px;
    height: 77px;
    border: 1px solid #D9D9D9;
  }

  .weui_uploader_files {
    list-style: none;
  }

  .weui_uploader_input_wrp:before {
    width: 2px;
    height: 39.5px;
  }

  .weui_uploader_input_wrp:before, .weui_uploader_input_wrp:after {
    content: " ";
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    background-color: #D9D9D9;
  }

  .weui_uploader_input {
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }

  .weui_uploader_input_wrp:after {
    width: 39.5px;
    height: 2px;
  }

  .weui_uploader_bd {
    overflow: hidden;
  }

  .outstore >>> .weui-uploader_files {
    list-style: none;
    overflow-y: hidden;
  }

  .outstore >>> .weui-uploader_file {
    float: left;
    margin-right: 9px;
    margin-bottom: 9px;
    width: 79px;
    background: no-repeat 50%;
    background-size: cover;
  }

  .weui-cell.fir {
    border-top: 0;
  }

  .weui_uploader_input_wrp.inrow {
    width: 30px;
    height: 30px;
    margin: 0;
  }

  .weui_uploader_input_wrp:before {
    height: 19.5px;
  }

  .weui_uploader_input_wrp:after {
    width: 19.5px;
  }

  .weui-uploader_file.inrow {
    margin: 0;
    width: 40px;
  }

  li.weui-uploader_file {
    display: inline-block;
    padding: 3px 5px;
  }

  ul#images {
    text-align: right;
  }
  .weui-cell.fir:before {
    border-top: 0;
  }
</style>
<template>
  <div class="sendcar">
    <div class="rj-wrap">
      派车信息
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px" /></a></div>
        <form method="post" id="formid">
    <div class="weui-tab">
      <div class="weui-navbar">
        <a class="weui-navbar__item" href="#tab1">订单信息</a>
        <a class="weui-navbar__item weui-bar__item_on" href="#tab2">派车信息</a>
      </div>
      <div class="weui-tab__panel">
        <div id="tab1" class="weui_tab_bd_item">
          <div class="weui-cells weui-cells_form">
            <input name="entity.guid" id="guid" type="hidden" v-model="adata.guid" />
            <input name="orderId" id="orderid" type="hidden" v-model="order.guid" />
            <input name="sellType" id="sellType" type="hidden" value="sendCar" />
            <input name="entity.wlcode" id="wlcompanyguid" v-model="adata.wlcode" type="hidden" />
            <input name="entity.code" id="code" v-model="adata.code" type="hidden" />
            <input name="wlstatus" id="wlstatus" v-model="wlinfoitem.wlstatus" type="hidden" />
            <input name="entity.faretype" id="faretype" value="1" type="hidden" />
            <input name="entity.farepricetype" id="farepricetype" value="1" type="hidden" />
            <input name="isSendCar" id="isSendCar" v-model="isSendCar" type="hidden" />
            <input name="sendcarguid" id="sendcarguid" v-model="sendcarguid" type="hidden" />
<!--            <input name="entitySea.seaguid" id="seaguid" v-model="bdata.guid" type="hidden" />-->
            <input name="entity.type" id="type" value="2" type="hidden" />
            <input name="entity.transtype" value="3" type="hidden" />
            <div class="cellgroup">
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">订单编号</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="text" readonly id="sellcode" v-model="order.sellcode" name="sellcode" placeholder="请输入订单编号"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">申请人</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" id="applyname" readonly type="text" name="applyname" v-model="order.applyname" placeholder="请输入申请人"></div>
              </div>
            </div>
            <div class="cellgroup">
              <div class="weui-cell fir">
                <div class="weui-cell__hd">
                  <label class="weui-label">发货联系人</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" id="delicontact" name="entity.delicontact" v-model="adata.delicontact" placeholder=" 请输入发货联系人"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">联系电话</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="number" id="delicontacttel" name="entity.delicontacttel" v-model="adata.delicontacttel" placeholder=" 请输入发货人手机号"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label id='unqualifiedchkrateDiv' class="weui-label">发货地址</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="text" id='deliprovince' name="entity.deliprovince"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">详细地址</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="text" id='deliaddress' name="entity.deliaddress" v-model="adata.deliaddress" placeholder=" 请输入发货详细地址"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">收货联系人</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" id="arricontact" name="entity.arricontact" v-model="adata.arricontact" placeholder="请输入收货联系人"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">联系电话</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="number" id="arricontactno" name="entity.arricontactno" v-model="adata.arricontactno" placeholder=" 请输入收货人手机号"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">收货地址</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="text" id='arriprovince' name="entity.arriprovince"></div>
              </div>
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">详细地址</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" type="text" id='arriaddres' name="entity.arriaddres" v-model="adata.arriaddres" placeholder=" 请输入收货详细地址"></div>
              </div>

            </div>
          </div>
        </div>
        <div id="tab2" class="weui_tab_bd_item weui_tab_bd_item_active">
          <div class="weui-cells weui-cells_form">
            <div class="weui-cell fir">
              <div class="weui-cell__hd">
                <label class="weui-label">运输方式</label></div>
              <div class="weui-cell__bd">
                <select class="weui-select" name="entity.transType" v-model="transType">
                  <option value="1">派车</option>
                  <option value="3">快递</option>
                </select>
              </div>
              <!--                  <input class="weui-input" ref="boxType" :disabled="wlinfoitem.wlstatus == 2" type="text" name="entitySea.boxType" v-model="bdata.boxType"  placeholder="请输入箱型"></div>-->
            </div>
            <div class="weui-cell" style="position: relative;">
              <div class="delsty"><i class="weui-icon-cancel" v-on:click="deleteCar"></i></div>
              <div class="weui-cell__hd">
                <label class="weui-label">物流公司</label></div>
              <div class="weui-cell__bd">
                <input class="weui-select" type="hidden" name="entity.customerid" id="customerid">
                <input class="weui-select" type="text" name="entity.customername" id="customername" :disabled="wlinfoitem.wlstatus == 2" placeholder="请输入物流公司" style="width: 80%;"></div>
            </div>
            <div class="weui-cell" v-if="transType == 3">
              <div class="weui-cell__hd">
                <label class="weui-label">快递单号</label></div>
              <div class="weui-cell__bd">
                <input class="weui-input" type="text" required name="entity.kdcode" placeholder="请输入快递单号">
              </div>
            </div>
            <div class="weui-cells weui-cells_form" v-if="transType == 1">
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">结算方式</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" readonly value="公司结算"></div>
              </div>
            </div>
            <div class="weui-cells weui-cells_form" v-if="transType == 1">
              <div class="weui-cell">
                <div class="weui-cell__hd">
                  <label class="weui-label">运费</label></div>
                <div class="weui-cell__bd">
                  <input class="weui-input" :disabled="wlinfoitem.wlstatus == 2" type="number" id="fareprice" name="entity.fareprice" placeholder="运价">
                </div>
              </div>
            </div>
            <div class="weui-cell" v-if="orderfiles.length > 0">
              <div class="weui-cell__hd"><label class="weui-label">附件</label></div>
              <div class="weui-cell__bd">
                <a v-for="(item, index) in orderfiles" :href="item.url">
                  <input class="weui-input" type="text" name="" :value="item.filename">
                </a>
                <!--              <input class="weui-input" type="text" name="" :value="baseInfo.createtime">-->
              </div>
            </div>
            <div class="weui-cell fir">
              <div class="weui-cell__hd"><label class="weui-label">附件上传</label></div>
              <!--          <div class="weui-cell__bd">-->
              <!--            <input class="weui-input" type="number" name="entity.lbweight" v-model="lbweight">-->
              <!--          </div>-->
              <div class="weui-cell__ft">
                <div class="weui_uploader_bd">
                  <ul class="weui_uploader_files"></ul>
                  <div class="weui_uploader_input_wrp inrow">
                    <UploadFile class="weui_uploader_input" v-on:pushfile="setFile" :orderid="order.guid"></UploadFile>
                  </div>
                </div>
              </div>
              <ul class="weui-uploader_files" id="images">
                <!--                  <li class="weui-uploader_file" v-for="(img, index) in filenames" :id="img"  @click=del(img,1) ><img :src="images1.srcStr[index]" width="85" /></li>-->
                <li class="weui-uploader_file" v-for="(fil, index) in filenames" @click=delFile(fil,fileids[index])>
                  {{fil}}
                </li>
              </ul>
            </div>
            <div class="weui-cell">
              <div class="weui-cell__bd">
                <textarea class="weui-textarea opinion" id="opinion" name="opinion" placeholder="请输入备注内容" rows="2"></textarea>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
          <div ref="actHtml" class="fixcont">
            <div class="weui-btn-area">
              <a class="weui-btn weui-btn_primary halfbtn subbtn" :disabled="wlinfoitem.wlstatus == 2" :class="{noprevent: wlinfoitem.wlstatus == 2}" href="javascript:" @click="send">提交</a>
              <a class="weui-btn weui-btn_primary halfbtn subbtn" v-if="refuseflag == 1" href="javascript:" @click="rejectIt">拒绝</a>
              <a class="weui-btn weui-btn_primary halfbtn" v-else href="javascript:" @click="$router.back(-1)" id="sub">返回</a></div>
          </div>
      <OrderBaseInfo :sellforms="sellforms" :transferapplys="transferapplys" :driveName="driveName"></OrderBaseInfo>
    </form>
    <div id="bmlogs">
      <SalesOperationLogs2 :nodeid="nodeid" :orderid="guid" :srguid="order.storermguid" :departid="order.depguid"></SalesOperationLogs2>
    </div>
  </div>
</template>

<script>
    import OrderBaseInfo from '../common/OrderBaseInfo'
    import SalesOperationLogs2 from '../common/SalesOperationLogs2'
    import UploadFile from "../common/UploadFile";

    export default {
    name: 'SendCar2',
    data () {
      return {
        guid : "",
        nodeid: '',
        status: '',
        adata: {}, //陆运
        bdata: {}, //海运
        adatas: [],
        transferapplys:[],
        sellforms:[],
        driveName:'',
        order:{},
        isSendCar: 0,  //0正常  1不能派车   2拼车,
        sendcarguid: '', //拼车的guid
        wlinfoitem: {},
        orderfiles: [],
        filenames: [],
        fileids: [],
        refuseflag: '',
        refuseNodes: [],
        transType: 1,
      }
    },
    created() {
      //刷新
      if (location.href.indexOf("#reloaded") == -1) {
        location.href = location.href + "#reloaded";
        location.reload();
      }
    },
    components: {
        OrderBaseInfo,
      SalesOperationLogs2,
      UploadFile
    },


    mounted () {
      //提交操作定位到页面底部
      //$('#bmlogs').css('margin-bottom', this.$refs.actHtml.offsetHeight);

      $('.weui-navbar__item').on('click', function () {
            $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');

            //内容切换
            $(".weui-tab__panel .weui_tab_bd_item_active").removeClass('weui_tab_bd_item_active');
            var data_toggle =jQuery(this).attr("href");
            $(data_toggle).addClass("weui_tab_bd_item_active");
        });


      // //编辑车牌号后赋值
      // $(".input_pp span").bind("DOMNodeInserted",function(e){
      //   var car = $('#cn0').text() + $('#cn1').text() + $('#cn2').text() + $('#cn3').text() + $('#cn4').text() + $('#cn5').text() + $('#cn6').text();
      //   $('#code').val(car);
      // })

      let that = this;
      this.guid = this.$route.query.guid;
      this.nodeid = this.$route.query.nodeid;
      //this.guid = this.$parent.getQueryVariable('guid');


      //获取回显数据
      $.ajax({
        url: '/wlinfo/Wlinfo!toSendCar.action',
        data: {orderid:that.guid,orderType:2},
        type: "post",
        dataType: "json",
        success: function(res) {
          if (res.msg == "success") {
            that.adata = {}
              if(res.wlinfos == undefined ){
                  that.adata.deliprovince = "";
                  that.adata.delicity="";
                  that.adata.delidistrict="";
                  that.adata.arriprovince = "";
                  that.adata.arricity="";
                  that.adata.arridistrict="";

              }else{
                console.log("res",res);
                  that.adatas = res.wlinfos;
                  that.order = res.order;
                  for(let i = 0; i < that.adatas.length; i++){
                    if(that.adatas[i].transtype == 2){
                      that.bdata = that.adatas[i]
                    }else{
                      that.adata = that.adatas[i]
                    }
                  }

                  let items = res.wlinfoitems;
                  for(let i = 0; i < items.length; i++){
                      if(items[i].wlinfoid == that.adata.guid){
                        that.wlinfoitem = items[i]
                      }
                  }


                  if(that.adata.faretype == 1){
                    $("#faretypeC").val("公司结算");
                  }else if(that.adata.faretype == 2){
                     $("#faretypeC").val("客户结算");
                  }

              }
            $('#orgguid').val(that.adata.orgguid);
            $('#deliprovince').val(that.adata.deliprovince + " " + that.adata.delicity + " " +that.adata.delidistrict);
            $('#arriprovince').val(that.adata.arriprovince + " " + that.adata.arricity + " " +that.adata.arridistrict);
             $('#guid').val(that.adata.guid);

            $('#customername').val(that.adata.customername);
            $('#customerid').val(that.adata.customerid);
            $('#fareprice').val(that.adata.fareprice);
          } else if (res != undefined && res.msg == 'sessionTimeOut') {
          //不不设置提示
        } else {
            that.toastError('系统出现异常!');
          }
        },
        complete: function () {

        }
      });
      //获取回显数据
      $.ajax({
        url: '/sales/Sellform!getWlCompany.action',
        data: {},
        type: "post",
        dataType: "json",
        success: function(res) {
          if (res.info != null) {

            var data = res.info;
            var datalist = new Array;
            $.each( data, function( index, itsm ) {
              var info = { "title": itsm.name, "value": itsm.guid };
              datalist.push(info);
            });

            $('#customername').select({
              title: "物流公司",
              items: datalist,
              onChange: function (data) {
                $('input[name="faretype"]').val($('#wlcompany').data('values'));
                $('#customername').val(data.titles);
                $('#customerid').val(data.values);
              }
            });

            $('#customernameSea').select({
              title: "物流公司",
              items: datalist,
              onChange: function (data) {
                $('#customernameSea').val(data.titles);
                $('#customeridSea').val(data.values);
              }
            });
          } else if (res != undefined && res.msg == 'sessionTimeOut') {
          //不不设置提示
        } else {
            that.toastError('系统出现异常!');
          }
        },
        complete: function () {

        }
      });


        $('#faretypeC').select({
            title: "运费结算方式",
            items: [{ "title":"公司结算", "value": 1 },{ "title":"客户结算", "value": 2 }],
            onChange: function (data) {
                $('input[name="wlcompanyguid"]').val($('#wlcompany').data('values'));
                $('#faretype').val(data.values);
            }
        });

      $("#deliprovince").cityPicker({
        title: "请选择发货地址",
      });
      $("#arriprovince").cityPicker({
        title: "请选择收货地址"
      });

      //编辑车牌号后赋值
      $(".input_pp span").bind("DOMNodeInserted",function(e){
        var car = $('#cn0').text() + $('#cn1').text() + $('#cn2').text() + $('#cn3').text() + $('#cn4').text() + $('#cn5').text() + $('#cn6').text();
        $('#carcode').val(car);
        console.log($('#carcode').val().length)


      })

      this.getFiles();
      this.refuseflag = this.$route.query.refuseflag;
      this.getRefuseNodes();
    },
    methods: {
      delFile: function (name, id) {
        let that = this;
        $.confirm('确定要删除？', function () {
          that.axios({
            method: 'post',
            url: '/sales/Fileinfo!delete.action',
            params: {fileid: id}
          })
          that.fileids = that.fileids.filter(item => {
            return item != id;
          })
          that.filenames = that.filenames.filter(item => {
            return item != name;
          })
        })
      },
      setFile: function (file) {
        this.filenames.push(file.name);
        this.fileids.push(file.id);
      },
      getFiles: function() {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Fileinfo!getFileinfo.action',
          params: {orderid: this.guid}
        }).then(response => {

          if (response.data.msg == 'success') {
            this.orderfiles = response.data.files;
          } else {
            //失败时不提示
          }
        });
      },
        deleteCar: function(){
          let that = this;
          var result = confirm("确认删除该派车信息？");
          if(!result){
            return;
          }
          var guid = $("#guid").val();
          if($('#carcode').val() == null || $('#carcode').val() == ""){
            that.toastText("该物流还没有进行派车");
            return;
          }
          $.ajax({
            url: '/wlinfo/Wlinfo!deleteCar.action',
            data: {linkcode : this.order.sellcode},
            type: "get",
            dataType: "json",
            success: function(res) {
              console.log("res",res)
              if(res.msg == "删除成功"){
                $('#carcode').val("");
                $("#driverphone").val("")
                $("#drivername").val("")
                $("#customerid").val("")
                $("#customername").val("")
                $("#fareprice").val("")
                $("#cn0").html("")
                $("#cn1").html("")
                $("#cn2").html("")
                $("#cn3").html("")
                $("#cn4").html("")
                $("#cn5").html("")
                $("#cn6").html("")
                that.toastText(res.msg)
                if (that.wlinfoitem.wlstatus == 2) {
                  that.$router.push({name: 'Sellform'});
                }
              }else{
                that.toastText(res.msg)
               // return;
              }
            }
          });
        },
        deleteSeaCar: function(){
          let that = this;
          var result = confirm("确认删除该派船信息？");
          if(!result){
            return;
          }
          var guid = $("#guid").val();
          if($('#customeridSea').val() == null || $('#customeridSea').val() == ""){
            that.toastText("该物流还没有进行派船");
            return;
          }
          $.ajax({
            url: '/wlinfo/Wlinfo!deleteSeaCar.action',
            data: {linkcode : this.order.sellcode},
            type: "get",
            dataType: "json",
            success: function(res) {
              console.log("res",res)
              if(res.msg == "删除成功"){
                $('#containerNo').val("");
                $("#deliPort").val("")
                $("#arriPort").val("")
                $("#customeridSea").val("")
                $("#customernameSea").val("")
                that.toastText(res.msg)
                if (that.wlinfoitem.wlstatus == 2) {
                  that.$router.push({name: 'Sellform'});
                }
              }else{
                that.toastText(res.msg)
              }
            }
          });
        },

        checkCarcode: function(e){
          $.ajax({
            url: '/wlinfo/Wlinfo!checkWlByCarcode.action',
            data: {carCode:e.target.value,status:7},
            type: "get",
            dataType: "json",
            success: function(res) {
              console.log("res",res)
              }
          });

        },
        send: function() {
          let that = this;
          if(!checkSubmit()){
            return;
          }

          //防止重复提交
          $('.subbtn').attr("disabled",true).css("pointer-events","none");
        //显示提交状态
        $.showLoading("正在提交");

          let postData = that.serialize2Obj($("#formid").serializeArray());
          postData.opinion = $('#opinion').val();
          postData.fileids = this.fileids.join(',');
          that.axios({
            method: 'post',
            url: '/wlinfo/Wlinfo!sendCar.action?nodeid=' + that.nodeid,
            params: postData
          }).then(response => {
            //恢复提交按钮可点击
            $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();
            if(response.data.info == "ok"){
              that.toastSuccess('操作成功!');
              that.$router.push({name: 'Sellform'});
            } else if (response.data.info == 'canotopt') {
              that.toastError('不允许的操作！');
            }else{
              that.toastError('操作失败!');

            }
          }).catch(function (error) {
            //恢复提交按钮可点击
            $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();
            that.toastError('系统错误');
          });

        },

      serialize2Obj: function (data) {
        var obj = {};
        $.each(data,function(i,v){
          obj[v.name] = v.value;
        })
        return obj;
      },
      setValues :function (){
            this.adata.sellcode=$('#sellcode').val();
            this.adata.applyname=$('#applyname').val();
            this.adata.delicontact=$('#delicontact').val();
            this.adata.delicontacttel=$('#delicontacttel').val();
            this.adata.deliprovince=$('#deliprovince').val();
            this.adata.deliaddress=$('#deliaddress').val();
            this.adata.arricontact=$('#arricontact').val();
            this.adata.arricontacttel=$('#arricontacttel').val();
            this.adata.arriprovince=$('#arriprovince').val();
            this.adata.arriaddres=$('#arriaddres').val();
            this.adata.customerid=$('#customerid').val();
            this.adata.customername=$('#customername').val();
            this.adata.driverphone=$('#driverphone').val();
            this.adata.drivername=$('#drivername').val();
            this.adata.carcode=$('#carcode').val();
            this.adata.fareprice=$('#fareprice').val();

      },
      openLogs: function() {
        this.$router.push({name: 'SalesOperationLogs2', query: {orderid: this.guid, srguid: this.order.storermguid, departid: this.order.depguid}});
      },
      getRefuseNodes: function() {
        let that = this;
        this.axios({
          method: 'get',
          url: '/sales/Flowtempnode!getRefuseNodes.action',
          params: {orderid: this.guid, nodeid: this.nodeid}
        }).then(response => {

          if (response.data.msg == 'success') {
            this.refuseNodes = response.data.optNodes.map(function (item) {
              return {text: item.name,
                onClick: function() {
                  $.confirm("确定要将订单回退到 " + item.name + " 节点？", function() {
                    that.doReject(item.guid, item.name, item.operatorid);
                  })
                }};
            });
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastText('获取可回退节点数据失败!');
          }
        });
      },
      rejectIt: function () {
        if (!this.checkEmy('opinion')) {
          this.toastText('意见不能为空！');
          return false;
        }
        if (this.refuseNodes.length > 0) {
          $.actions({
            title: '选择回退节点',
            actions: this.refuseNodes
          });
        } else {
          this.toastText('无可回退节点！');
          return false;
        }
      },
      doReject: function (refuseNodeid, refuseNodename, refuseOperatorid) {
        let that = this;

        //防止重复提交
        $('.subbtn').attr("disabled",true).css("pointer-events","none");
        //显示提交状态
        $.showLoading("正在提交");

        let postData = {};
        // postData.imgids = this.images.serverId.join(',');
        postData.imgids = '';
        postData.sellformid = this.guid;
        postData.opinion = ($('#opinion').val() || '') + ' 退回到' + refuseNodename;
        postData.nodeid = this.nodeid;
        postData.refuseNodeid = refuseNodeid;
        postData.backUserid = refuseOperatorid;
        this.axios({
          method: 'post',
          url: '/sales/Sellform!refuse.action',
          params: postData
        }).then((response) => {
          //恢复提交按钮可点击
          $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();

          if (response.data.msg == 'success') {
            this.toastSuccess('提交成功!');
            this.$router.push({name: 'Sellform'});
          } else if (response.data.msg == 'canotRefuse') {
            this.toastText('不允许拒绝，需删除子订单！');
          } else if (response.data.msg == 'canotopt') {
            this.toastText('不允许的操作！');
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastError('系统错误');
          }
        }).catch(function (error) {
          //恢复提交按钮可点击
          $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();
          that.toastError('系统错误');
        });
      }
    }
  }

  /**
   * 提交之前的校验
   */
  function checkSubmit(){
    //物流公司
    if(isEmpty("customerid")){
      alert("请选择物流公司");
      return false;
    }
    return true;
  }

  function isEmpty(domID){

    return $('#' + domID).val() == "" || $('#' + domID) == null;
  }

</script>
